#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sxlb.h"


int main(void) {
    double_list_t list = createEmptyDoubleLinkList();
    if (list == NULL) {
        printf("创建双向链表失败!\n");
        return 1;
    }

    printf("添加元素\n");
    insertIntoDoubleLinkList(list, 0, 1);
    insertIntoDoubleLinkList(list, 1, 2);
    insertIntoDoubleLinkList(list, 1, 2);
    insertIntoDoubleLinkList(list, 2, 3);
    insertIntoDoubleLinkList(list, 2, 3);
    insertIntoDoubleLinkList(list, -1, 3);
    insertIntoDoubleLinkList(list, 2, 88);




    printf("遍历\n");
    showDoubleLinkList(list);

    printf("删除元素\n");
    deletePostDoubleLinkList(list, 1);

    printf("删除元素后\n");
    showDoubleLinkList(list);

    printf("是否空\n");
    if (isEmptyDoubleLinkList(list)) {
        printf("非空\n");
    } else {
        printf("空\n");
    }

    printf("长度\n");
    printf("Length: %d\n", lengthDoubleLinkList(list));

    printf("查找数据3位置\n");
    
    printf("%d\n",searchPostDoubleLinkList(list, 3));

    printf("修改1位置数据为99\n");
    printf("修改3位置数据为77\n");

    changeDataDoubleLinkList(list, 1, 99);
    changeDataDoubleLinkList(list, 3, 77);

    showDoubleLinkList(list);

    printf("删除数据3\n");
    deleteDataDoubleLinkList(list, 3);
    showDoubleLinkList(list);

    return 0;
}